﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Petzold.Media3D;
using System.Windows.Media.Media3D;
using System.Windows.Media;
using System.ComponentModel;

namespace PistonWheel
{
    public class Rod:Cylinder,INotifyPropertyChanged,ICloneable
    {
        private double _time;

        public double L{ get; set; }

        public double Mass { get; set; }

        public new Point3D Point1
        {
            get
            {
                return base.Point1;
            }
            set
            {
                if (!base.Point1.Equals( value ))
                {
                    base.Point1 = value;
                }
            }
        }

        public new Point3D Point2
        {
            get
            {
                return base.Point2;
            }
            set
            {
                if(!base.Point2.Equals(value))
                {
                    base.Point2 = value;
                }
            }
        }

        public double Time
        {
            get
            {
                return this._time;
            }
            set
            {
                if (this._time != value)
                {
                    this._time = value;
                    this.NotifyPropertyChanged( "Time" );
                }
            }
        }

        /// <summary>
        /// Psi angle that the motion is defined about
        /// </summary>
        public double Angle { get; set; }

        /// <summary>
        /// Angular velocity measured in the psi angle
        /// </summary>
        public double AngularVelocity { get; set; }

        /// <summary>
        /// Length's standart deviation, according to normal distribution function
        /// </summary>
        public double LengthStdDev { get; set; }

        internal Wheel Wheel { get; set; }

        public Rod(Brush backBrushMaterial,Brush frontBrushMaterial,Wheel wheel)
            : base()
        {
            DiffuseMaterial backMaterial = new DiffuseMaterial( backBrushMaterial );
            this.BackMaterial = backMaterial;
            DiffuseMaterial frontMaterial = new DiffuseMaterial( frontBrushMaterial );
            this.Material = frontMaterial;
            this.Wheel = wheel;
            this.Angle = 0.0;
            this.AngularVelocity = 0.0;
        }

        #region INotifyPropertyChanged Members

        public new event PropertyChangedEventHandler PropertyChanged;

         private void NotifyPropertyChanged(String info)
        {
            if (PropertyChanged != null)
            {
                PropertyChanged( this, new PropertyChangedEventArgs( info ) );
            }
        }
        #endregion

         #region ICloneable Members

         public object Clone()
         {
             return this.MemberwiseClone();
         }

         #endregion
    }
}
